require "rubygems"
require "active_record"

class AddDeployedAtAttributeToDeployment < ActiveRecord::Migration
  include Wondercap::Deployment
  
  def self.up
    add_column :deployments, :deployed_at, :datetime, :default => Time.now, :null => false
    execute "UPDATE deployments SET deployed_at = (SELECT created_at FROM snapshots WHERE snapshots.id = deployments.snapshot_id)"
  end
  
end